<?php
// Fonction de surlignage
function highlight($field){
	if(isset($_GET['s'])){
		$chaine = $_GET['s'];
		$chaine_r = utf8_decode ( $chaine );
		$value2 = utf8_decode ( $field );
		$chaine_r = preg_replace ("/\\W/",".",$chaine_r);
		$value1 = preg_replace("/($chaine_r)/i", '<span class="highlight">$1</span>', $value2);
		$field = utf8_encode($value1);
	}
	$field = preg_replace("/\n/", '<br/>', $field);
	return $field;
}

include('../config/config.php');
function printField($i, $fieldTitle, $fieldValue){
	echo '	<tr';
	if (($i & 1)==1) echo ' class="odd"';
	echo ">\n		<td class=\"fieldTitle\">".$fieldTitle." : </td>\n";
	echo '		<td>'.$fieldValue."</td>\n";
	echo "	</tr>\n";
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr">
<head>
	<meta http-equiv="content-Type" content="text/html; charset=utf-8"/>
	<meta http-equiv="Content-Language" content="fr"/>
	<title>Vue détaillée</title>
 	<meta name="language" content="fr-FR" />
	<meta name="robots" content="nofollow" />
	<meta name="keywords" content="<?php echo $longTitle;?>" />
	<meta name="author" content="Archives Henri Poincaré"/>
	<meta name="publisher" content="Laboratoire d'Histoire des Sciences et de Philosophie" />
	<meta name="copyright" content="Université Nancy 2, CNRS" />
	<style type="text/css" media="screen">@import url(./styles/noticeBib.css);</style>
	<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"/>
</head>
<body>
<div id="main" style="padding:0 1em;">
	<div id="searchForm" style="">
<?php
// Fichier de configuration fonction du serveur
include('../config/config.php');
$dsn='mysql:host='.$host.';port='.$port.';dbname='.$dbname;

include("../model/model.php");
$a = new model($dsn, $user, $pass);

$item = $a->selectItem($from, 'id', $_GET['id']);
?>

<div style="font-weight:bold; padding-bottom:0.5em;">Notice détaillée</div>
<table id="viewItem">
<?php
if(isset($debug) and $debug==true) print_r($item[0]);

$i='';
if(!empty($item[0]['code'])){$i++; printField($i, 'Cote', highlight($item[0]['code']));}
if(!empty($item[0]['title'])){$i++;printField($i, 'Sous-collection', highlight($item[0]['title']));}
if(!empty($item[0]['title_a'])){$i++;printField($i, 'Titre', highlight($item[0]['title_a']));}
if(!empty($item[0]['author'])){$i++;printField($i, 'Auteur', highlight($item[0]['author']));}
if(!empty($item[0]['content'])){$i++;printField($i, 'Résumé', highlight($item[0]['content']));}
if(!empty($item[0]['pagination'])){$i++;printField($i, 'Pagination', highlight($item[0]['pagination']).' p');}
if(!empty($item[0]['date'])){$i++;printField($i, 'Date', highlight($item[0]['date']));}
if(!empty($item[0]['keywords'])){$i++;printField($i, 'Mot-clé', highlight($item[0]['keywords']));}
if(!empty($item[0]['size'])){$i++;printField($i, 'Taille', highlight($item[0]['size']).' Mo');}
if(!empty($item[0]['url_md'])){$i++;printField($i, 'URL', highlight($item[0]['url_md']));}
if(!empty($item[0]['see_also'])){$i++;printField($i, 'Voir aussi', highlight($item[0]['see_also']));}

// Calcul des URL pour le titre et les champs myrl et url
$urlMyrl='';
$libMyrl='';
$titleMyrl='';
$urlUrl='';
$titleLink='';
$urlTitle='';
	// Calcul de $urlMyrl et $libMyrl
	if(!empty($item[0]['myrl'])){
		$extension=substr(strrchr($item[0]['myrl'],'.'),1) ;
		if ($extension=='pdf') {$urlMyrl = 'http://www.univ-nancy2.fr/poincare/bhp/pdf/'.$item[0]['myrl'];$libMyrl = '<span class="pdfLogo">&nbsp;</span>';}
		elseif ($extension=='xml') {$urlMyrl = 'http://www.univ-nancy2.fr/poincare/bhp/'.$item[0]['myrl'];$libMyrl = 'XML';}
		elseif ($extension=='html') {$urlMyrl = 'http://www.univ-nancy2.fr/poincare/bhp/'.$item[0]['myrl'];$libMyrl = 'HTML';}
		else {$libMyrl = $item[0]['myrl'].', ';}
		$titleMyrl='Accès au texte intégral via AHP';
	}
	// Calcul de $urlUrl
	if(!empty($item[0]['url'])){
		// Gestion des & pour un code valide
		$urlUrl = preg_replace("/\&/","&amp;",$item[0]['url']);
		$domain = explode('/', $item[0]['url']);
		$titleLink='Accès via '.$domain[2];
	}
	// Calcul de $urlTitle pour le titre
	if(!empty($urlMyrl)) {$urlTitle=$urlMyrl;$titleTitle=$titleMyrl;}
	elseif(!empty($value['url'])) {$urlTitle=$urlUrl;$titleTitle=$titleLink;}

//notes
if(!empty($item[0]['nt'])){
	$i++;
	printField($i, 'Notes', $item[0]['nt']);
}
// BibTeX
if(!empty($item[0]['bibref'])){
	$i++;
	$bibref=preg_replace("/\t/","<br/>",$item[0]['bibref']);
	printField($i, 'BibTeX', $bibref);
}

// Calcul PDF AHP
if(!empty($urlMyrl)) {
	$valueMyrl='<a style="text-decoration:none;" href="'.$urlMyrl.'" target="_blank" title="'.$titleMyrl.'">'.$libMyrl.'</a>'."\n";
}
// pas d'extension
else $valueMyrl=$libMyrl."\n";

// Calcul PDF autres archives
if(!empty($urlUrl)){
	$valueUrl='<a style="text-decoration:none;" href="'.$urlUrl.'" target="_blank" title="'.$titleLink.'">'.$titleLink.'</a>'."\n";
}

// PDF AHP
if(!empty($item[0]['myrl'])){
	$i++;
	printField($i, 'via AHP', $valueMyrl);
}
// autre archive
if(!empty($valueUrl)){
	$i++;
	printField($i, 'Archive', $valueUrl);
}

// Google scholar
/*$scholar='';
if(isset($item[0]['titre'])){
	$scholar .= '<a title="Rechercher" target="_blank" href="';
	$scholar .= 'http://scholar.google.com/scholar?btnG=Search%2BScholar&as_q=';
	$scholar .= urlencode('"'.$item[0]['titre'].'"');
	$scholar .= '">Rechercher</a>';
}
$i++;
printField($i, 'Google Scholar', $scholar);
*/

?>
</table>

	</div>
</div>

</body>
</html>
